<?php

namespace App\Console\Commands;

use App\Models\Configuration;
use App\Models\GoodsOrder;
use Carbon\Carbon;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
use danielme85\Geoip2\Facade\Reader;

class ShopOrderCancelCommand extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'shoporder:cancel';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '商品订单支付超时自动取消';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    public function handle()
    {
        $now = Carbon::now();
        GoodsOrder::where('order_status', '=', GoodsOrder::ORDER_UNPAID)
            ->where('add_time', '<', $now->subMinutes(Configuration::getItem('waiting_payment')))
            ->update(['order_status' => GoodsOrder::ORDER_TIME_OUT_CANCEL]);
    }









}
